package com.czkevin.guicontrolsapi;

import de.tr7zw.nbtapi.NBTCompound;
import de.tr7zw.nbtapi.NBTCompoundList;
import de.tr7zw.nbtapi.NBTItem;
import de.tr7zw.nbtapi.NBTListCompound;
import org.bukkit.Material;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.Arrays;
import java.util.List;

public class HeadTools {

    public static final ItemStack HEAD_ARROW_UP = getHead(
        "\u00a76\u00a7l↑",
        Arrays.asList("\u00a77Move up. "),
        new int[]{-455626629,1509707639,-1333022652,1615387860},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThmZTI1MWE0MGU0MTY3ZDM1ZDA4MWMyNzg2OWFjMTUxYWY5NmI2YmQxNmRkMjgzNGQ1ZGM3MjM1ZjQ3NzkxZCJ9fX0="
    );
    public static final ItemStack HEAD_ARROW_DOWN = getHead(
        "\u00a76\u00a7l↓",
        Arrays.asList("\u00a77Move down. "),
        new int[]{-858494473,502350585,-1995106850,947455716},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWI3Y2U2ODNkMDg2OGFhNDM3OGFlYjYwY2FhNWVhODA1OTZiY2ZmZGFiNmI1YWYyZDEyNTk1ODM3YTg0ODUzIn19fQ=="
    );
    public static final ItemStack HEAD_ARROW_LEFT = getHead(
        "\u00a76\u00a7l←",
        Arrays.asList("\u00a77Move left. "),
        new int[]{799899974,409685148,-1939702436,-888651862},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmIwZjZlOGFmNDZhYzZmYWY4ODkxNDE5MWFiNjZmMjYxZDY3MjZhNzk5OWM2MzdjZjJlNDE1OWZlMWZjNDc3In19fQ=="
    );
    public static final ItemStack HEAD_ARROW_RIGHT = getHead(
        "\u00a76\u00a7l→",
        Arrays.asList("\u00a77Move right. "),
        new int[]{-1839528166,2088977383,-1652322525,478287828},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjJmM2EyZGZjZTBjM2RhYjdlZTEwZGIzODVlNTIyOWYxYTM5NTM0YThiYTI2NDYxNzhlMzdjNGZhOTNiIn19fQ=="
    );

    public static final ItemStack HEAD_IRON_SPEECH_BUBBLE = HeadTools.getHead(
        "\u00a76\u00a7lButton",Arrays.asList("\u00a77Click. "),
        new int[]{-58427836,340019647,-1623153198,-911483678},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQ4Y2UxY2YxOGFmMDVhNTc2ZDYwODEyMzAwMWI3OTFmZWRiNjIyOTExZWY4ZDM4YTMyMGRhM2JjYmY2ZmQyMCJ9fX0=");

    public static final ItemStack HEAD_IRON_SPEECH_BUBBLE_ATTENTION = HeadTools.getHead(
        "\u00a76\u00a7lButton",Arrays.asList("\u00a77Click. "),
        new int[]{1893688659,1044860267,-2050716749,494871218},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWY2NDAyMjY1ZGFjYWNhM2FiNjMxNDNhOWM5NTA4YzcxOTFkYTgzMDEwZTk3NzA3YjQ3ZmIxMDkyY2ZhOTg3YSJ9fX0=");

    public static final ItemStack HEAD_IRON_SPEECH_BUBBLE_QUESTION = HeadTools.getHead(
        "\u00a76\u00a7lButton",Arrays.asList("\u00a77Click. "),
        new int[]{1088751130,-155237707,-1757115564,-449695775},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGU0YTFlZTJhMGE3NTg1NDU2MzZlMzhlMzNiM2JhYjZmNGRlMGU4MzZhMDdlODQ3ZDI4MmYxZTc2Yjk0MWY3MSJ9fX0=");

    public static final ItemStack HEAD_IRON_CROSS = HeadTools.getHead(
        "\u00a76\u00a7lButton",Arrays.asList("\u00a77Click. "),
        new int[]{-357038652,-1170846806,-2078329597,496329811},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTljZGI5YWYzOGNmNDFkYWE1M2JjOGNkYTc2NjVjNTA5NjMyZDE0ZTY3OGYwZjE5ZjI2M2Y0NmU1NDFkOGEzMCJ9fX0=");

    public static final ItemStack HEAD_IRON_CHECK = HeadTools.getHead(
        "\u00a76\u00a7lButton",Arrays.asList("\u00a77Click. "),
        new int[]{-1260349759,1706183357,-1092819336,1119568561},
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2UyYTUzMGY0MjcyNmZhN2EzMWVmYWI4ZTQzZGFkZWUxODg5MzdjZjgyNGFmODhlYThlNGM5M2E0OWM1NzI5NCJ9fX0=");

    public static ItemStack getHead(String name, List<String> lore, int[] skullOwner, String texture) {
        ItemStack head = new ItemStack(Material.PLAYER_HEAD);
        ItemMeta m = head.getItemMeta();
        m.setDisplayName(name);
        m.setLore(lore);
        m.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
        head.setItemMeta(m);

        NBTItem nbt = new NBTItem(head);
        NBTCompound skull = nbt.addCompound("SkullOwner");
        skull.setIntArray("Id", skullOwner);
        NBTCompound props = skull.addCompound("Properties");
        NBTCompoundList textures = props.getCompoundList("textures");
        NBTListCompound tex = textures.addCompound();
        tex.setString("Value", texture);

        return nbt.getItem();
    }

}
